package com.tran.app.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.tran.app.data.PlainData
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow

@Dao
interface PlainDataDao {
    @Insert
    fun insertPlainData(plainData: PlainData): Long

    @Update
    fun updatePlainData(plainData: PlainData): Int

    @Delete
    fun deletePlainData(plainData: PlainData): Int

    @Query("SELECT * FROM PlainData")
    fun getAllPlainData(): List<PlainData>

    @Query("SELECT * FROM PlainData WHERE id = :id")
    fun getPlainDataById(id: Int): Flow<PlainData>

    @Query("SELECT * FROM PlainData WHERE user = :user")
    fun getPlainDataByUser(user: String): Flow<List<PlainData?>>
    // 可以添加更多查询方法
}